---
// 产品数据接口定义
interface ProductSpecs {
  generalTraffic: string; // 通用流量
  directionalTraffic: string; // 定向流量
  callMinutes: string; // 通话时长
  smsCount?: string; // 短信条数
  validityPeriod?: string; // 有效期
}

interface ProductEligibility {
  minAge: number; // 最小年龄
  maxAge: number; // 最大年龄
  regions?: string[]; // 适用地区
  restrictions?: string[]; // 其他限制条件
}

interface ProductStats {
  claimedCount: number; // 已领取人数
  rating: number; // 1-5星评分
  reviewCount?: number; // 评价数量
  successRate?: number; // 办理成功率
}

interface Product {
  id: string;
  name: string;
  shortName?: string; // 简短名称
  price: number;
  originalPrice?: number; // 原价，用于显示折扣
  monthlyFee: number; // 月租费用
  image: string;
  badge?: 'new' | 'hot' | 'recommended' | 'limited'; // 产品标签
  description: string;
  specs: ProductSpecs; // 产品规格
  eligibility: ProductEligibility; // 办理条件
  stats: ProductStats; // 统计信息
  features?: string[]; // 产品特色
  provider: 'unicom' | 'mobile' | 'telecom'; // 运营商
  category: 'data' | 'voice' | 'combo'; // 产品类别
  isActive: boolean; // 是否可办理
  priority?: number; // 显示优先级
}

// 示例产品数据
const products: Product[] = [
  {
    id: "prod-01",
    name: "联通专用卡【29元139G+100分钟】",
    shortName: "湖北联通专用卡",
    price: 29,
    originalPrice: 39,
    monthlyFee: 29,
    image: "https://haokaapi.lot-ml.com/upload/ProductUpDateImage/20250702/907f5512f6f34773bce18b4871be5e74.jpg",
    badge: "hot",
    description: "联通专用流量卡，超值套餐，高性价比选择",
    specs: {
      generalTraffic: "139G",
      directionalTraffic: "0G",
      callMinutes: "100分钟",
      validityPeriod: "长期有效"
    },
    eligibility: {
      minAge: 18,
      maxAge: 60,
      regions: ["湖北省"],
      restrictions: ["需实名认证", "一人限办一张"]
    },
    stats: {
      claimedCount: 346542,
      rating: 4.8,
      reviewCount: 12580,
      successRate: 98.5
    },
    features: ["超大流量", "通话包含", "湖北专享", "快速激活"],
    provider: "unicom",
    category: "combo",
    isActive: true,
    priority: 1
  },
  {
    id: "prod-02",
    name: "联通省内卡【29元135G+100分钟】",
    shortName: "湖北联通省内卡",
    price: 29,
    originalPrice: 39,
    monthlyFee: 29,
    image: "https://haokaapi.lot-ml.com/upload/ProductUpDateImage/20250408/835bcd8dad874f19b264e763f584bd5c.jpg",
    badge: "recommended",
    description: "联通省内专属套餐，超大流量优惠",
    specs: {
      generalTraffic: "135G",
      directionalTraffic: "0G",
      callMinutes: "100分钟",
      validityPeriod: "长期有效"
    },
    eligibility: {
      minAge: 18,
      maxAge: 60,
      regions: ["湖北省"],
      restrictions: ["需实名认证"]
    },
    stats: {
      claimedCount: 523587,
      rating: 4.9,
      reviewCount: 8520,
      successRate: 99.2
    },
    features: ["省内专享", "超大流量", "性价比高", "快速办理"],
    provider: "unicom",
    category: "combo",
    isActive: true,
    priority: 2
  },
  {
    id: "prod-03",
    name: "省内产品集合中心",
    shortName: "省内产品集合",
    price: 29,
    monthlyFee: 29,
    image: "https://haokaapi.lot-ml.com/upload/ProductUpDateImage/20240809/d91b218ae73a4025b3a0e16a30748e19.jpg",
    badge: "recommended",
    description: "省内专属套餐集合，超值优惠套餐",
    specs: {
      generalTraffic: "105G",
      directionalTraffic: "30G",
      callMinutes: "100分钟",
      validityPeriod: "长期有效"
    },
    eligibility: {
      minAge: 18,
      maxAge: 60,
      regions: ["全国"],
      restrictions: ["需实名认证", "限省内用户"]
    },
    stats: {
      claimedCount: 32314986,
      rating: 4.8,
      reviewCount: 15680,
      successRate: 99.2
    },
    features: ["省内专享", "超大流量", "性价比高", "快速办理"],
    provider: "unicom",
    category: "combo",
    isActive: true,
    priority: 3
  },
  {
    id: "prod-04",
    name: "电信飞诗卡【首年19元80G】",
    shortName: "电信飞诗卡",
    price: 19,
    monthlyFee: 19,
    image: "https://haokaapi.lot-ml.com/upload/ProductUpDateImage/20250705/45aed7c617c8404793fafcdc15c7bd50.jpg",
    badge: "hot",
    description: "19元50G通用+30G定向",
    specs: {
      generalTraffic: "50G",
      directionalTraffic: "30G",
      callMinutes: "0分钟",
      validityPeriod: "长期有效"
    },
    eligibility: {
      minAge: 18,
      maxAge: 60,
      regions: ["全国"],
      restrictions: ["需实名认证"]
    },
    stats: {
      claimedCount: 1233099,
      rating: 4.8,
      reviewCount: 3250,
      successRate: 98.5
    },
    features: ["超大流量", "性价比高", "首年特惠", "全国通用"],
    provider: "telecom",
    category: "data",
    isActive: true,
    priority: 4
  },
];

// 组件属性
interface Props {
  title?: string;
  subtitle?: string;
}

const { 
  title = "为您精选优质流量套餐", 
  subtitle = "热门产品推荐" 
} = Astro.props;
---

<!-- ====== 产品轮播组件 开始 -->
<section class="relative z-20 overflow-hidden bg-white dark:bg-dark pt-20 pb-12 lg:pt-[120px] lg:pb-[90px]">
  <div class="container mx-auto">
    <div class="flex flex-wrap -mx-4">
      <div class="w-full px-4">
        <div class="mx-auto mb-[60px] max-w-[620px] text-center">
          <span class="block mb-2 text-lg font-semibold text-primary">
            {subtitle}
          </span>
          <h2 class="text-dark dark:text-white mb-4 text-3xl leading-[1.2] font-bold sm:text-4xl md:text-[40px]">
            {title}
          </h2>
        </div>
      </div>
    </div>

    <!-- 产品轮播 -->
    <div class="product-carousel -mx-4 flex flex-wrap">
      {products.map((product) => (
        <div class="w-full px-4 md:w-1/2 lg:w-1/3 xl:w-1/4">
          <div class="wow fadeInUp relative mb-12 overflow-hidden rounded-lg bg-white dark:bg-dark-2 shadow-1 transition-all hover:shadow-3 dark:shadow-card dark:hover:shadow-3">
            <div class="relative overflow-hidden">
              <!-- 产品图片 -->
              <img src={product.image || "/assets/products/placeholder.jpg"} alt={product.name} class="w-full h-[240px] object-cover" />
              
              <!-- 产品标签 -->
              {product.badge && (
                <span class={`absolute top-4 right-4 rounded-full py-1 px-3 text-xs font-semibold text-white ${
                  product.badge === 'new' ? 'bg-green-500' : 
                  product.badge === 'hot' ? 'bg-red-500' : 
                  product.badge === 'recommended' ? 'bg-blue-500' : 
                  'bg-orange-500'
                }`}>
                  {product.badge === 'new' ? '新品' : 
                   product.badge === 'hot' ? '热门' : 
                   product.badge === 'recommended' ? '推荐' : 
                   '限时'}
                </span>
              )}
              
              <!-- 产品悬停效果已移除 -->
            </div>
            
            <div class="p-6">
              <!-- 产品名称 -->
              <h3 class="mb-2 text-xl font-semibold text-dark dark:text-white">
                {product.name}
              </h3>
              
              <!-- 产品评分和统计 -->
              <div class="mb-3 flex items-center justify-between">
                <div class="flex items-center">
                  {Array.from({ length: 5 }).map((_, i) => (
                    <span class={`${i < Math.floor(product.stats.rating) ? 'text-yellow-500' : (i < product.stats.rating ? 'text-yellow-300' : 'text-gray-300')}`}>
                      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-4 h-4">
                        <path fill-rule="evenodd" d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z" clip-rule="evenodd" />
                      </svg>
                    </span>
                  ))}
                  <span class="ml-1 text-xs text-gray-500">({product.stats.rating})</span>
                </div>
                <span class="text-xs text-green-600 font-medium">{product.stats.claimedCount.toLocaleString()}人已领取</span>
              </div>
              
              <!-- 产品规格 -->
              <div class="mb-3 text-xs text-gray-600 dark:text-gray-400">
                <div class="flex justify-between mb-1">
                  <span>通用流量:</span>
                  <span class="font-medium text-primary">{product.specs.generalTraffic}</span>
                </div>
                <div class="flex justify-between mb-1">
                  <span>通话时长:</span>
                  <span class="font-medium">{product.specs.callMinutes}</span>
                </div>
                <div class="flex justify-between">
                  <span>适用年龄:</span>
                  <span class="font-medium">{product.eligibility.minAge}-{product.eligibility.maxAge}周岁</span>
                </div>
              </div>
              
              <!-- 产品价格 -->
              <div class="mb-4 flex items-center">
                <span class="text-xl font-semibold text-primary mr-2">¥{product.price}</span>
                {product.originalPrice && (
                  <span class="text-sm text-gray-400 line-through">¥{product.originalPrice}</span>
                )}
              </div>
              
              <!-- 产品描述 -->
              <p class="text-sm text-body-color dark:text-dark-6 mb-4">
                {product.description}
              </p>
              
              <!-- 添加立即申请和立即办理按钮 -->
              <div class="flex space-x-2">
                <a href="https://h5.lot-ml.com/ProductEn/Index/1a654e0b341cadd2" target="_blank" rel="noopener noreferrer" class="inline-flex items-center justify-center px-4 py-2 text-sm font-medium text-white bg-primary hover:bg-primary-dark transition-colors">
                  立即申请
                </a>
                <a href="https://h5.lot-ml.com/ProductEn/Index/1a654e0b341cadd2" target="_blank" rel="noopener noreferrer" class="inline-flex items-center justify-center px-4 py-2 text-sm font-medium text-primary border border-primary hover:bg-primary hover:text-white transition-colors">
                  立即办理
                </a>
              </div>
            </div>
          </div>
        </div>
      ))}
    </div>
  </div>

  <!-- ====== Product Section End -->
  <!-- 背景装饰 -->
  <div>
    <span class="absolute top-4 left-4 -z-[1]">
      <svg width="48" height="134" viewBox="0 0 48 134" fill="none" xmlns="http://www.w3.org/2000/svg">
        <circle cx="45.6673" cy="132" r="1.66667" transform="rotate(180 45.6673 132)" fill="#13C296" />
        <circle cx="45.6673" cy="117.333" r="1.66667" transform="rotate(180 45.6673 117.333)" fill="#13C296" />
        <circle cx="45.6673" cy="102.667" r="1.66667" transform="rotate(180 45.6673 102.667)" fill="#13C296" />
        <circle cx="45.6673" cy="88.0001" r="1.66667" transform="rotate(180 45.6673 88.0001)" fill="#13C296" />
        <circle cx="45.6673" cy="73.3335" r="1.66667" transform="rotate(180 45.6673 73.3335)" fill="#13C296" />
        <circle cx="45.6673" cy="45.0001" r="1.66667" transform="rotate(180 45.6673 45.0001)" fill="#13C296" />
        <circle cx="45.6673" cy="16.0001" r="1.66667" transform="rotate(180 45.6673 16.0001)" fill="#13C296" />
        <circle cx="45.6673" cy="59.0001" r="1.66667" transform="rotate(180 45.6673 59.0001)" fill="#13C296" />
        <circle cx="45.6673" cy="30.6668" r="1.66667" transform="rotate(180 45.6673 30.6668)" fill="#13C296" />
        <circle cx="45.6673" cy="1.66683" r="1.66667" transform="rotate(180 45.6673 1.66683)" fill="#13C296" />
        <circle cx="31.0013" cy="132" r="1.66667" transform="rotate(180 31.0013 132)" fill="#13C296" />
        <circle cx="31.0013" cy="117.333" r="1.66667" transform="rotate(180 31.0013 117.333)" fill="#13C296" />
        <circle cx="31.0013" cy="102.667" r="1.66667" transform="rotate(180 31.0013 102.667)" fill="#13C296" />
        <circle cx="31.0013" cy="88.0001" r="1.66667" transform="rotate(180 31.0013 88.0001)" fill="#13C296" />
        <circle cx="31.0013" cy="73.3335" r="1.66667" transform="rotate(180 31.0013 73.3335)" fill="#13C296" />
        <circle cx="31.0013" cy="45.0001" r="1.66667" transform="rotate(180 31.0013 45.0001)" fill="#13C296" />
        <circle cx="31.0013" cy="16.0001" r="1.66667" transform="rotate(180 31.0013 16.0001)" fill="#13C296" />
        <circle cx="31.0013" cy="59.0001" r="1.66667" transform="rotate(180 31.0013 59.0001)" fill="#13C296" />
        <circle cx="31.0013" cy="30.6668" r="1.66667" transform="rotate(180 31.0013 30.6668)" fill="#13C296" />
        <circle cx="31.0013" cy="1.66683" r="1.66667" transform="rotate(180 31.0013 1.66683)" fill="#13C296" />
      </svg>
    </span>
    <span class="absolute bottom-4 right-4 -z-[1]">
      <svg width="48" height="134" viewBox="0 0 48 134" fill="none" xmlns="http://www.w3.org/2000/svg">
        <circle cx="45.6673" cy="132" r="1.66667" transform="rotate(180 45.6673 132)" fill="#3758F9" />
        <circle cx="45.6673" cy="117.333" r="1.66667" transform="rotate(180 45.6673 117.333)" fill="#3758F9" />
        <circle cx="45.6673" cy="102.667" r="1.66667" transform="rotate(180 45.6673 102.667)" fill="#3758F9" />
        <circle cx="45.6673" cy="88.0001" r="1.66667" transform="rotate(180 45.6673 88.0001)" fill="#3758F9" />
        <circle cx="45.6673" cy="73.3333" r="1.66667" transform="rotate(180 45.6673 73.3333)" fill="#3758F9" />
        <circle cx="45.6673" cy="45.0001" r="1.66667" transform="rotate(180 45.6673 45.0001)" fill="#3758F9" />
        <circle cx="45.6673" cy="16.0001" r="1.66667" transform="rotate(180 45.6673 16.0001)" fill="#3758F9" />
        <circle cx="45.6673" cy="59.0001" r="1.66667" transform="rotate(180 45.6673 59.0001)" fill="#3758F9" />
        <circle cx="45.6673" cy="30.6668" r="1.66667" transform="rotate(180 45.6673 30.6668)" fill="#3758F9" />
        <circle cx="45.6673" cy="1.66683" r="1.66667" transform="rotate(180 45.6673 1.66683)" fill="#3758F9" />
        <circle cx="31.0006" cy="132" r="1.66667" transform="rotate(180 31.0006 132)" fill="#3758F9" />
        <circle cx="31.0006" cy="117.333" r="1.66667" transform="rotate(180 31.0006 117.333)" fill="#3758F9" />
        <circle cx="31.0006" cy="102.667" r="1.66667" transform="rotate(180 31.0006 102.667)" fill="#3758F9" />
        <circle cx="31.0006" cy="88.0001" r="1.66667" transform="rotate(180 31.0006 88.0001)" fill="#3758F9" />
        <circle cx="31.0008" cy="73.3333" r="1.66667" transform="rotate(180 31.0008 73.3333)" fill="#3758F9" />
        <circle cx="31.0008" cy="45.0001" r="1.66667" transform="rotate(180 31.0008 45.0001)" fill="#3758F9" />
        <circle cx="31.0008" cy="16.0001" r="1.66667" transform="rotate(180 31.0008 16.0001)" fill="#3758F9" />
        <circle cx="31.0008" cy="59.0001" r="1.66667" transform="rotate(180 31.0008 59.0001)" fill="#3758F9" />
        <circle cx="31.0008" cy="30.6668" r="1.66667" transform="rotate(180 31.0008 30.6668)" fill="#3758F9" />
        <circle cx="31.0008" cy="1.66683" r="1.66667" transform="rotate(180 31.0008 1.66683)" fill="#3758F9" />
      </svg>
    </span>
  </div>
</section>
<!-- ====== 产品轮播组件 结束 -->

<style>
  /* 产品卡片悬停效果 */
  .product-carousel .wow {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
  }
  
  .product-carousel .wow:hover {
    transform: translateY(-5px);
  }
  
  /* 移除了产品操作按钮相关样式 */
</style>

<script>
  // 移除了产品卡片交互效果相关代码
  document.addEventListener('DOMContentLoaded', () => {
    // 获取所有产品卡片
    const productCards = document.querySelectorAll('.product-carousel .wow');
    
    // 基本卡片效果可以保留
  });
</script>
<!-- ====== Product Section End -->